<?php

include(dirname(__FILE__) . '/dsendmail2-2010-07-20/dSendMail2.inc.php');
//require_once './dsendmail2-2010-07-20/dSendMail2.inc.php';

// First of all: DISABLE TIME LIMIT and IGNORE USER ABORT! You really don't want to be interrupted in the middle of this.
//set_time_limit(0);
//ignore_user_abort(true);
// Parameters:
// ->sendThroughSMTP($smtp_server, $port=25, $user=false, $pass=false, $ssl=false)
class MailMannagament extends dSendMail2 {

	var $smtp = "mail.infomaniak.ch";
	var $smtp_port = 25;
	var $user = "webmaster@arena-park.ch";
	var $pass = "comeasyouare";

	public function MailMannagament() {

		parent::__construct();
	}

	public function sendContract($user, $file) {

		$this->setTo( $user['email'] );
		$this->setFrom("info@arena-park.ch");
		$this->setSubject("Bienvenue chez Arena-Park");
		
		$content = "<img src='http://www.arena-park.ch/images/Logo.jpg' style='float: right; width: 100px; height: 100px' />
<p>
	Bonjour<br/>
	".$user['sex'].". ".$user['last_name']." ".$user['name'].",<br/><br/>
	". utf8_decode("Ci-joint vous trouvez votre contrat. Le document doit être
    imprimé et présenté au voiturier le jour de la prise en charge.")."
</p>
<br/>
<p>
	".  utf8_decode("Vous avez besoin d`informations complémentaires? Vous pouvez contacter notre service par téléphone au +41(0)22 840 83 50 ou par e-mail à l`adresse suivante: 
info@arena-park.ch")."

	<br/>
	<br/>
	Cordialement, <br/>
	<i>
		".  utf8_decode("Votre équipe ARENA-PARK.CH")."<br/>
			".  utf8_decode("4, rue du Grand-Pré")."
		 
	</i><br/>".  utf8_decode("CP/localité 1202. Genève")."</p>";
		$this->setMessage( $content );

		$this->sendThroughSMTP($this->smtp, $this->smtp_port, $this->user, $this->pass);

		$this->autoAttachFile($file);


		if($this->send()){
			
			$this->setTo( "reservation@arena-park.ch" );
		    $this->setFrom($user["email"]);
		    $this->setSubject("Reserva ". date('d-m-Y H:i'));
			$this->setMessage( "" );
			
			return ($this->send());
		}
		
		return 0;
		
		
	}
	
	public function sendContactRequest($contactRequest){
		
		$this->setTo('contact@arena-park.ch');
		$this->setFrom( $contactRequest['email'] );
		$this->setSubject( ($contactRequest['subject'])?$contactRequest['subject']:'Sin asunto');
		$this->setMessage( $contactRequest['content'] );

		$this->sendThroughSMTP($this->smtp, $this->smtp_port, $this->user, $this->pass);

		return ($this->send())? 1: 0;
	}

}

?>
